<template>
  <!-- Main content -->
  <section class="content">
    <div class="box box-info">
      <div class="box-header with-border">
        <h3 class="box-title">仓库设置</h3>
      </div>
      <div class="box-body">
        <div class="form-horizontal">
          <div class="form-group m-b-n">
            <div class="col-sm-12 flex">
              <label class="min-width bg-gray control-label">仓库名称：</label>
              <div class="inline-block">
                <input type="text" class="form-control pull-left"
                       placeholder="请输入仓库名称" v-model.trim="storageListParam.name" style="width: 350px;">
                <button class="btn bg-green pull-left m-lr-10" @click="searchShName">搜 索</button>
                <button class="btn btn-danger pull-left m-lr-10" @click="resetName">重 置</button>
              </div>
            </div>
          </div>
        </div>
        <!-- /.box-body -->

        <!-- /.box-footer -->
      </div>
    </div>
    <div class="row">
      <div class="col-xs-12">
        <div class="box box-info">
          <div class="box-header with-border">
            <h3 class="box-title">仓库设置</h3>
            <button v-if="$_has('sys:repertory:add')" type="button" class="btn btn-primary pull-right"
                    data-toggle="modal" data-target="#modal-default"
                    @click="addStorage">
              添加新仓库
            </button>
          </div>
          <!-- /.box-header -->
          <div class="box-body">
            <table class="table table-bordered table-striped dataTable">
              <div class="overlay" v-if="show">
                <i class="fa fa-refresh fa-spin"></i>
              </div>
              <thead>
              <tr>
                <th style="width: 6%">序号</th>
                <th>仓库名称</th>
                <th>仓库类型</th>
                <th>负责人</th>
                <th>状态</th>
                <th style="width: 40%;">仓库地址</th>
                <th style="width: 26%">操作</th>
              </tr>
              </thead>
              <tbody>
              <tr v-if="storageList.length == 0">
                <td colspan="7">
                  没有数据
                </td>
              </tr>
              <tr v-else v-for="(storageListItem,index) in storageList">
                <td>{{((pageNum-1)*10)+index+1}}</td>
                <td class="text-left">{{storageListItem.whName}}</td>
                <td>{{storageListItem.whType == 1 ? "海外仓库" : "本地仓库"}}</td>
                <td>{{storageListItem.userName}}</td>
                <td>{{storageListItem.status == 1 ? "启动" : "禁用"}}</td>
                <td class="text-left">{{storageListItem.proName}} - {{storageListItem.cityName}} -
                  {{storageListItem.dictName}} -
                  {{storageListItem.address}}
                </td>
                <td class="bisectrix">
                  <span>
                    <a v-if="$_has('sys:stock:list')" class="text-info m-lr-10" data-toggle="modal"
                       data-target="#modal-default2"
                       @click="getShelfList(storageListItem.id)">货架管理</a>
                  </span>
                  <span>
                    <a v-if="$_has('sys:repertory:edit')" class="text-green m-lr-10" data-toggle="modal"
                       data-target="#modal-default"
                       @click="editorStorage(storageListItem.id)">编辑</a>
                  </span>
                  <span>
                    <a class="text-green m-lr-10" v-if="$_has('sys:repertory:del')"
                       @click="deleteStorage(storageListItem.id,1)">删除</a>
                  </span>
                  <span>
                    <a class="text-green m-lr-10"
                       @click="enabledStorage(storageListItem.id,storageListItem.status)"
                       v-if="$_has('sys:repertory:edit')">{{storageListItem.status == 0 ?
                    "启动" :
                    "禁用"}}</a>
                  </span>

                  <span>
                    <a class="text-green m-lr-10"
                       @click="defaultdStorage(storageListItem.id)"
                       v-if="storageListItem.status == 1 && $_has('sys:repertory:edit')">{{storageListItem.firstWh == 0 ? '设为默认仓':''}}</a>
                  </span>
                </td>
              </tr>
              </tbody>
            </table>
            <div class="clearfix" v-if="storageList.length != 0">
              <div class="pull-right">
                <pagination :total="pages.storage.total" :current-page='pages.storage.current'
                            :display="pages.storage.display" @pagechange="pagechange"></pagination>
              </div>
            </div>
          </div>
          <!-- /.box-body -->
        </div>
        <!-- /.box -->

      </div>
      <!-- /.col -->
    </div>
    <!-- /.row -->


    <div class="modal fade" id="modal-default">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title">{{storageTitle}}</h4>
          </div>
          <div class="modal-body">
            <div class="form-horizontal">
              <div class="box-body">
                <div class="form-group">
                  <div class="flex">
                    <label class="control-label min-width bg-gray">仓库名称：</label>
                    <div class="inline-block">
                      <input type="text" class="form-control" v-model="editorInfo.name" name="name" placeholder="仓库名称">
                    </div>
                  </div>
                </div>
                <div class="form-group">
                  <div class="flex">
                    <label for="" class="control-label min-width bg-gray">负责人：</label>
                    <div class="inline-block">
                      <select name="owner" class="form-control select2" v-model="editorInfo.owner">
                        <option value="">请选择负责人</option>
                        <option :value="principalListItem.userId" v-for="principalListItem in principalList">
                          {{principalListItem.name}}
                        </option>
                      </select>
                    </div>
                  </div>
                </div>
                <div class="form-group">
                  <div class="flex">
                    <label for="" class="control-label min-width bg-gray">类型：</label>
                    <div class="inline-block">
                      <select name="whType" class="form-control" v-model="editorInfo.whType">
                        <!--<option :value="editorInfo.whType">{{editorInfo.whType}}</option>-->
                        <option value="">请选择默认仓库</option>
                        <option value="1">海外仓库</option>
                        <option value="0">本地仓库</option>
                      </select>
                    </div>
                  </div>
                </div>
                <div class="form-group">
                  <div class="flex">
                    <label for="" class="control-label min-width bg-gray">所在地区：</label>
                    <div class="row" style="width: 100%;">
                      <div class="col-sm-4">
                        <select name="province" class="form-control" v-model="editorInfo.province"
                                @change="getCitys(editorInfo.province)">
                          <option value="">-请选择省-</option>
                          <option v-for="provinceItem in province" :value="provinceItem.id">{{provinceItem.name}}
                          </option>
                        </select>
                      </div>
                      <div class="col-sm-4">
                        <select name="city" class="form-control" v-model="editorInfo.city"
                                @change="getAreas(editorInfo.city)">
                          <option value="">-请选择市-</option>
                          <option v-for="cityItem in city" :value="cityItem.id">{{cityItem.name}}</option>
                        </select>
                      </div>
                      <div class="col-sm-4">
                        <select name="district" class="form-control" v-model="editorInfo.district">
                          <option value="">-请选择区-</option>
                          <option v-for="areaItem in area" :value="areaItem.id">{{areaItem.name}}</option>
                        </select>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="form-group">
                  <div class="flex">
                    <label for="" class="control-label min-width bg-gray">地址：</label>
                    <div class="inline-block">
                      <textarea name="address" class="form-control" v-model="editorInfo.address" rows="3"></textarea>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-primary m-r-10" @click="submitStorage">保存</button>
            <button type="button" class="btn btn-default " data-dismiss="modal">关闭</button>
          </div>
        </div>
        <!-- /.modal-content -->
      </div>
      <!-- /.modal-dialog -->
    </div>
    <div class="modal fade" id="modal-default2">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <span aria-hidden="true" aria-label="Close" class="pull-right"><span
              data-toggle="modal" data-target="#modal-default3" class="btn btn-primary"
              @click="addShelf">添加货架</span></span>
            <h4 class="modal-title">货架管理</h4>
          </div>
          <div class="modal-body">
            <div class="box-body">
              <table class="table table-bordered table-hover box">
                <div class="overlay" v-if="show">
                  <i class="fa fa-refresh fa-spin"></i>
                </div>
                <thead>
                <tr>
                  <th>货架名称</th>
                  <th>货架编号</th>
                  <th>库位规格</th>
                  <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr v-if="shelfList.length == 0">
                  <td colspan="4">
                    没有数据
                  </td>
                </tr>
                <tr v-else v-for="(shelfListItem,index) in shelfList">
                  <td>{{shelfListItem.shelfName}}</td>
                  <td>{{shelfListItem.shelfNo}}</td>
                  <td>
                    {{shelfListItem.rowNum}}层{{shelfListItem.columnNum}}列
                  </td>
                  <td>
                    <span aria-hidden="true" aria-label="Close">
                      <a class="text-info m-lr-10" data-toggle="modal" data-target="#modal-default3"
                         @click="editorShelf(shelfListItem.id)" v-if="$_has('sys:stock:edit')">编辑</a>
                    </span>
                    <a class="text-info m-lr-10" @click="deleteShelf(shelfListItem.id,index)"
                       v-if="$_has('sys:stock:del')">删除</a>
                  </td>
                </tr>
                </tbody>
              </table>
              <div class="clearfix" v-if="shelfList.length != 0">
                <div class="m-t-15 pull-right">
                  <pagination :total="pages.shelfList.total" :current-page='pages.shelfList.pageNum'
                              :display="pages.shelfList.pageSize"
                              @pagechange="pagechange1"></pagination>
                </div>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
          </div>
        </div>
        <!-- /.modal-content -->
      </div>
      <!-- /.modal-dialog -->
    </div>
    <div class="modal fade" id="modal-default3">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title">{{shelfInfo}}</h4>
          </div>
          <div class="modal-body">
            <div class="box-body">
              <div class="form-horizontal">
                <div class="form-group">
                  <div class="row">
                    <div class="col-sm-6 flex">
                      <label for="" class="control-label min-width bg-gray"><sup class="text-red">*</sup>货架名称：</label>
                      <div class="inline-block">
                        <input type="text" class="form-control" name="shelfNo"
                               v-model="shelfListDetail.whShelf.shelfName"
                               placeholder="请输入货架名称">
                      </div>
                    </div>
                    <div class="col-sm-6 flex" v-if="shelfListDetail.whShelf.whName">
                      <label for="" class="control-label min-width bg-gray">所属仓库：</label>
                      <div class="inline-block">
                        <label for="" class="control-label">{{shelfListDetail.whShelf.whName}}</label>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="form-group">
                  <div class="row">
                    <div class="col-sm-6 flex">
                      <label for="" class="control-label bg-gray min-width"><sup class="text-red">*</sup>货架编号：</label>
                      <div class="inline-block">
                        <input type="text" name="shelfNo" class="form-control" v-model="shelfListDetail.whShelf.shelfNo"
                               placeholder="请输入货架编号">
                      </div>
                    </div>
                    <div class="col-sm-6 flex">
                      <label for="" class="control-label bg-gray min-width">库位前缀：</label>
                      <div class="inline-block">
                        <input type="text" name="shelfPre" v-model="shelfListDetail.whShelf.shelfPre"
                               class="form-control"
                               placeholder="xx">
                      </div>
                    </div>
                  </div>
                </div>
                <div class="form-group">
                  <div class="row">
                    <div class="col-sm-12 flex">
                      <label for="" class="control-label min-width bg-gray">货架规格：</label>
                      <div class="inline-block">
                        <input type="text" name="rowNum" class="form-control pull-left" style="width: 30%"
                               placeholder="3"
                               v-model.number="shelfListDetail.whShelf.rowNum">
                        <span class=" pull-left span-alok">层</span>
                        <input type="text" name="columnNum" class="form-control pull-left" style="width: 30%"
                               placeholder="3"
                               v-model.number="shelfListDetail.whShelf.columnNum">
                        <span class=" pull-left span-alok">列</span>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="form-group">
                  <div class="row">
                    <div class="col-sm-12">
                      <label for="" class="control-label">编号格式：</label>
                      <label for="" class="control-label text-red">库位前缀 - 货架标号 - 层 - 列</label>
                    </div>
                  </div>
                </div>

                <div class="form-group">
                  <div class="row">
                    <div class="col-sm-12">
                      <table class="table table-bordered">
                        <tbody>
                        <tr>
                          <td></td>
                          <td v-for="(columnNumItem, index) in shelfListDetail.whShelf.columnNum" :key="index">
                            {{columnNumItem}}列
                            {{shelfListDetail.whShelf.columnNum}}
                          </td>
                        </tr>
                        <tr v-for="(rowNumItem, index) in shelfListDetail.whShelf.rowNum" :key="index">
                          <td>{{rowNumItem}}行</td>
                          <td v-for="(columnNumItem, index) in shelfListDetail.whShelf.columnNum" :key="index"
                              class="whStockListInfo">
                            {{shelfListDetail.whShelf.shelfPre}}-{{columnNumItem}}-{{rowNumItem}}
                          </td>
                        </tr>
                        </tbody>
                      </table>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-primary m-r-10" @click="submitShelf">保存</button>
            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
          </div>
        </div>
        <!-- /.modal-content -->
      </div>
      <!-- /.modal-dialog -->
    </div>

    <transition name="fade">
      <div v-if="errorShow" class="gritter-notice-wrapper " :class="{'success-notice-wrapper':errorClass}">
        <div id="gritter-item-4" class="gritter-item-wrapper gritter-error" style="" role="alert">
          <div class="gritter-item"><a class="gritter-close" tabindex="1" @click="closeError"><i
            class="fa fa-close"></i></a>
            <div class="gritter-without-image"><span class="gritter-title">{{errorTitle}}</span>
              <p>{{errorMsg}}</p></div>
          </div>
        </div>
      </div>
    </transition>

  </section>
  <!-- /.content -->


</template>

<script>
  import pagination from '@/components/common/pageComponent'
  import instance from '@/api/index.js'
  // import slided from '../../assets/dist/js/adminlte.min.js'

  export default {
    name: "storageSetting",
    data() {
      return {
        show: false,//loading
        storageList: [],//获取仓库列表数据
        storageListParam: {},//获取仓库列表传参
        pages: {//分页
          storage: {
            current: 1,
            total: 0,
            display: 10
          },
          shelfList: {
            total: 0,
            pageNum: 1,
            pageSize: 10
          }
        },
        pageNum: 1,//序号
        storageTitle: "",//编辑或者添加仓库标题
        editorInfo: {
          owner: '',
          whType: '',
          province: '',
          city: '',
          district: '',
        },//编辑

        shelfList: [],//货架列表
        shelfListParam: {},//货架列表传参
        shelfListDetail: {
          whShelf: {},
          whStockList: []
        },//货架详情
        shelfInfo: '',//货架弹框名称

        provincesList: [],//省市区
        principalList: [],//负责人
        usPpout: false,//弹框
        notarize: '',//确认信息

        province: [],//省
        city: [],//市
        area: [],//区
        shelfName: '',
        amendParam: {},//修改状态
        errorShow: false,//错误显示
        errorMsg: '',//错误信息
        errorTitle: '',//错误提示标题
        errorClass: false,//错误样式
      }
    },
    methods: {
      //消息弹窗提示
      alertMessage: function (value) {
        let type = 'success'
        if (!value.success) {
          type = 'error'
        }
        this.$message({
          showClose: false,
          message: value.msg,
          type: type
        });
      },
      // 获取分页
      pagechange: function (currentPage) {
        this.storageListParam.page = currentPage;
        this.getStorageList();
      },
      pagechange1: function (currentPage, display) {
        let vm = this;
        this.shelfListParam.page = currentPage;
        this.shelfListParam.rows = display;
        this.getShelfList(vm.shelfListParam.whId);
      },

      // //定时信息提示
      // setTime:function(){
      //   let vm = this;
      //   setTimeout(function () {
      //     vm.errorShow = false;
      //   },2500)
      // },
      //
      // //关闭信息提示
      // closeError:function(){
      //   this.errorShow = false;
      // },

      //获取仓库列表
      getStorageList: function () {
        let vm = this;
        vm.show = true;
        vm.storageListParam.rows = 20;
        vm.pages.storage.display = vm.storageListParam.rows;
        instance.post('/v1/warehouse/getWareHouseList', vm.storageListParam).then(function (data) {
          vm.show = false;
          vm.storageList = data.data.data.list;
          vm.pages.storage.total = data.data.data.total;
          vm.pageNum = data.data.data.pageNum;
        })
      },

      //编辑仓库
      editorStorage: function (id) {
        let vm = this;
        let storageId = {};
        storageId.id = id
        vm.storageTitle = "编辑仓库";

        instance.post('/v1/warehouse/getWareHouse/' + id).then(function (data) {
          vm.editorInfo = data.data.data;
          vm.getPrincipal();
          vm.getProvCityAreaList();
          vm.getCitys(vm.editorInfo.province);
          vm.getAreas(vm.editorInfo.city);
        });
      },

      //删除仓库
      deleteStorage: function (id) {
        let vm = this;
        for (let key in vm.amendParam) {
          delete vm.amendParam[key]
        }
        vm.amendParam.id = id;
        vm.amendParam.delFlag = 1;
        vm.$confirm('此操作将删除此仓库, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          instance.post('/v1/warehouse/updateWareHouse', vm.amendParam).then(function (data) {
            vm.alertMessage(data.data);
            vm.getStorageList();
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
        })
      },

      //搜索仓库名称
      searchShName: function () {
        this.getStorageList();
      },

      resetName: function () {
        this.storageListParam.name = '';
        this.getStorageList();
      },

      //获取负责人
      getPrincipal: function () {
        let vm = this;
        instance.post('/user/getUserSelectList').then(function (data) {
          if (data.data.success) {
            vm.principalList = data.data.data;
          }
        })
      },

      //添加仓库
      addStorage: function () {
        this.storageTitle = "添加仓库";
        for (let key in this.editorInfo) {
          this.editorInfo[key] = ""
        }
        ;
        this.getPrincipal();
        this.getProvCityAreaList();
      },
      //保存仓库
      submitStorage: function () {
        let vm = this;
        let postUrl = '';
        let id = this.editorInfo.id;
        if (id) {
          postUrl = '/v1/warehouse/updateWareHouse';
        } else {
          postUrl = '/v1/warehouse/addWareHouse'
        }
        ;
        if (!vm.editorInfo.name) {
          vm.$alert('请输入仓库名称', '提示', {
            confirmButtonText: '确定',
          });
          return;
        }
        instance.post(postUrl, vm.editorInfo).then(function (data) {
          // if(data.data.success){
          //   vm.errorClass = true;
          //   vm.errorShow = true;
          //   vm.errorTitle = "操作成功";
          //   vm.errorMsg = data.data.msg;
          //   vm.setTime();
          //   vm.getStorageList();
          // }
          vm.alertMessage(data.data);
          $("#modal-default").modal('hide');
          vm.getStorageList();
        })
      },

      //启用
      enabledStorage: function (id, statue) {
        let vm = this;
        for (let key in vm.amendParam) {
          delete vm.amendParam[key]
        }
        let value;
        vm.amendParam.id = id;
        if (statue == 0) {
          value = '启动'
          vm.amendParam.status = 1;
        } else {
          value = '禁用'
          vm.amendParam.status = 0;
        }
        vm.$confirm('确定' + value + '该仓库？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          instance({
            method: 'post',
            url: '/v1/warehouse/updateWareHouse',
            data: vm.amendParam
          }).then(function (data) {
            vm.alertMessage(data.data);
            vm.getStorageList();
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
        })
      },

      //设置默认仓库
      defaultdStorage: function (id) {
        let vm = this;
        for (let key in vm.amendParam) {
          delete vm.amendParam[key]
        }
        vm.amendParam.id = id;
        vm.amendParam.firstWh = 1;
        vm.$confirm('确定设置此仓库为默认仓？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          instance({
            method: 'post',
            url: '/v1/warehouse/updateWareHouse',
            data: vm.amendParam
          }).then(function (data) {
            vm.alertMessage(data.data);
            vm.getStorageList();
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
        })
      },

      //获取货架列表数据
      getShelfList: function (whId) {
        let vm = this;
        delete vm.shelfListParam.id;
        this.shelfListParam.whId = whId;
        this.shelfListParam.rows = 5;
        this.show = true;
        instance.post('/v1/warehouse/getShelfList', vm.shelfListParam).then(function (data) {
          vm.shelfList = data.data.data.list;
          vm.pages.shelfList = data.data.data;
          vm.shelfListDetail.whId = whId;
          vm.show = false;
        })
      },

      //编辑货架
      editorShelf: function (id) {
        let vm = this;
        vm.shelfInfo = "编辑货架";
        vm.shelfListParam.id = id;
        vm.shelfListDetail.whShelf = {};
        vm.shelfListDetail.whStockList = [];
        instance.post('/v1/warehouse/getShelfDetail/' + id).then(function (data) {
          console.log(data)
          vm.shelfListDetail.whShelf = data.data.data.whShelf;
          vm.shelfListDetail.whStockList = data.data.data.whStockList;
        })
      },

      //删除货架
      deleteShelf: function (id) {
        let vm = this;
        vm.$confirm('此操作将删除此货架以及全部库位, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          instance.post('/v1/warehouse/deleteShelf/' + id).then(function (data) {
            let type =  'error'
            if (data.data.success) {
              type = 'success'
            }
            vm.$message({
              showClose: false,
              message: data.data.msg,
              type: type
            });
            vm.getShelfList(vm.shelfListParam.whId);
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
        })
      },

      //添加货架
      addShelf: function () {
        this.shelfInfo = "添加货架";
        this.shelfListDetail.whShelf = {};
        this.shelfListDetail.whStockList = [];
      },

      //提交货架
      submitShelf: function () {
        let shelfParams = {};//获取表单数据
        let transferParams = {};//传参
        let vm = this;
        for (let key in this.shelfListDetail.whShelf) {
          shelfParams[key] = this.shelfListDetail.whShelf[key];
        }
        let whStockListLength = this.shelfListDetail.whShelf.columnNum * this.shelfListDetail.whShelf.rowNum;
        transferParams.whStockList = [];
        for (let i = 0; i < this.shelfListDetail.whShelf.columnNum; i++) {
          for (let j = 0; j < this.shelfListDetail.whShelf.rowNum; j++) {
            let newwhStockList = {};
            newwhStockList.stockNo = this.shelfListDetail.whShelf.shelfPre + "-" + (i + 1) + "-" + (j + 1);
            transferParams.whStockList.push(newwhStockList);
          }
        }
        shelfParams.whId = this.shelfListParam.whId;

        transferParams.whShelf = shelfParams;
        let postUrl = '';
        if (transferParams.whShelf.id) {
          postUrl = '/v1/warehouse/editShelf'

        } else {
          postUrl = '/v1/warehouse/addShelf'
        }
        if (!transferParams.whShelf.shelfName) {
          vm.$alert('请输入货架名称', '提示', {
            confirmButtonText: '确定',
          });
          return;
        }
        ;
        if (!transferParams.whShelf.shelfNo) {
          vm.$alert('请输入货架编号', '提示', {
            confirmButtonText: '确定',
          });
          return;
        }
        ;
        if (!transferParams.whShelf.shelfPre) {
          vm.$alert('请输入库位前缀', '提示', {
            confirmButtonText: '确定',
          });
          return;
        }
        ;
        if (!transferParams.whShelf.columnNum) {
          vm.$alert('请输入货架规格', '提示', {
            confirmButtonText: '确定',
          });
          return;
        }
        ;
        if (!transferParams.whShelf.rowNum) {
          vm.$alert('请输入货架规格', '提示', {
            confirmButtonText: '确定',
          });
          return;
        }
        ;
        instance.post(postUrl, transferParams).then(function (data) {
          let type =  'error'
          if (data.data.success) {
            type = 'success'
          }
          vm.$message({
            showClose: false,
            message: data.data.msg,
            type: type
          });
          vm.getShelfList(vm.shelfListDetail.whId);
          $("#modal-default3").modal('hide');
        });
      },

      //获取省
      getProvCityAreaList: function (id) {
        let vm = this;
        vm.city = [];
        vm.area = [];
        // vm.editorInfo.city = '';
        // vm.editorInfo.district = '';
        instance.post('/sys/getProvCityAreaList').then(function (data) {
          vm.province = data.data.data;
        })
      },

      //获取市，地区
      getCitys: function (id) {
        let vm = this;
        vm.area = [];
        // vm.editorInfo.city = '';
        // vm.editorInfo.district = '';
        instance.post('/sys/getProvCityAreaList/' + id,).then(function (data) {
          vm.city = data.data.data;
        })
      },

      //获取区县
      getAreas: function (id) {
        let vm = this;
        instance.post('/sys/getProvCityAreaList/' + id,).then(function (data) {
          vm.area = data.data.data;
        })
      },


    },
    created() {
      //获取仓库列表
      // this.storageListParam.enterpriseId = 1;
      this.getStorageList();
    },
    components: {
      pagination
    }
  }


</script>

<style scoped>
</style>
